package com.central.apps.dao.MaterialInventory;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Map;

@Mapper
public interface inventoryDao {
    @Select("select standardcost from gq_item where itemnum = #{itemnum}")
    String getStandardcostByStorenum(String itemnum);
    @Select("select avgcost from gq_invcost " +
            "where storenum = #{storenum} and itemnum = #{itemnum} and batchnum = #{batchnum} limit 0,1")
    String getAvgcostBySIB(Map<String, Object> params);

    @Select("select curbal from gq_invbalances " +
            "where storenum = #{storenum} and itemnum = #{itemnum} and binnum = #{binnum} and batchnum = #{batchnum} limit 0,1")
    Integer getCurbalBySIBB(Map<String, Object> params);

    @Insert("insert into gq_invcost(stdcost,avgcost,lastcost,storenum,itemnum,batchnum) " +
            "values(#{stdcost},#{avgcost},#{lastcost},#{storenum},#{itemnum},#{batchnum})")
    void insertInvcost(Map<String, Object> params);

    @Update("update gq_invcost set avgcost = #{avgcost},lastcost = #{lastcost} " +
            "where storenum = #{storenum} and itemnum = #{itemnum} and batchnum = #{batchnum}")
    void updateInvcost(Map<String, Object> params);



}
